<template>
  <div class="header">
    <div class="main">
      <a :href="url">
        <!-- <img src="@/assets/img/WechatIMG233.png" alt /> -->
      </a>
      <div class="username">
        <!-- <div v-if="userName">
          {{userName}}，欢迎您的登录!
          <el-button type="text" @click="logout">退出</el-button>
        </div>
        <div v-else>
          <a href="" class="login">登录</a>
          <a href="" class="reg">登录</a>
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
import { logout } from '../../api/index';
export default {
  data () {
    return {
      userName: '',
      url: ''
    };
  },
  created () {
    this.userName = localStorage.getItem('ep_userName');
    this.url = process.env.VUE_APP_URL;

  },
  methods: {
    logout () {
      logout().then(data => {
        console.log(data);
        if (data.success) {
          localStorage.removeItem('ep_Authorization');
          this.$router.push({ path: '/login' });
        } else {
          this.$message.error(`${data.msg}`);
        }
      });
    }
  }
};
</script>

<style lang="css" scoped>
.header {
    width: 100%;
    height: 40px;
    background: rgba(0, 147, 255, 1);
    opacity: 1;
}
.header .main {
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    height: 100%;
}
.header .main .username {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 20px;
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 20px;
    color: rgba(255, 255, 255, 1);
    opacity: 1;
}
.reg {
    margin-left: 58px;
}
.header .main div a {
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    opacity: 1;
}
a.old_Edition {
    width: 64px;
    height: 20px;
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 20px;
    color: rgba(255, 255, 255, 1);
    opacity: 1;
    margin-left: 70px;
}
.el-button {
    margin-left: 10px;
    width: 48px;
    height: 21px;
    background: rgba(24, 147, 252, 1);
    border: 1px solid rgba(75, 172, 252, 1);
    opacity: 1;
    border-radius: 4px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 0;
    color: rgba(255, 255, 255, 1);
}
</style>